#ifndef __REVERB_H__
#define __REVERB_H__

#define array_size(x) (sizeof(x) / sizeof((x)[0]))

class Reverb
{
public:
    Reverb(double sampleRate);
    ~Reverb();

    void setMix(float newMix);           // 0.0 to 100.0
    void setTone(float newTone);         // 0.0 to 100.0
    void setFeedback(float newFeedback); // 0.0 to 100.0
    void setDamp(float newDamp);         // 0.0 to 100.0

    void process(const float* input, float* output, size_t numSamples);

private:

    typedef struct {
        size_t  sample_size;
        float   * buffer, * ptr;
        float   store;
    } reverb_filter_t;

    const size_t comb_lengths[8] = {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617},
                 allpass_lengths[4] = {225, 341, 441, 556};

    double sampleRate = 44100.0;
    float mix = 0.0f;      // Wet/Dry mix
    float tone = 0.0f;     // Tone control
    float feedback = 0.0f; // Feedback amount
    float damp = 0.0f;     // Damping factor
    float newMix = 0.5f;
    float newTone = 0.5f;
    float newFeedback = 0.5f;
    float newDamp = 0.5f;

    float lastOutput = 0.0f;

    reverb_filter_t filterComb[array_size(comb_lengths)];
    reverb_filter_t filterAllpass[array_size(allpass_lengths)];


    float comb_process(reverb_filter_t * p, float const input, float feedback, float hf_damping);
    float allpass_process(reverb_filter_t * p, float input);

};


#endif // __REVERB_H__
